﻿/*******************************************************************************
 * Copyright © 2016 NFine.Framework 版权所有
 * Author: NFine
 * Description: NFine快速开发平台
 
*********************************************************************************/
using NFine.Code;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace NFine.Web.Areas.ExampleManage.Controllers
{
    public class SendMailController : ControllerBase
    {
        /// <summary>
        /// 发送邮件
        /// </summary>
        /// <param name="mailName">发件人名称</param>
        /// <param name="account">收件人</param>
        /// <param name="title">主题</param>
        /// <param name="content">内容</param>
        /// <returns></returns>
        [HttpPost]
        [HandlerAjaxOnly]
        [ValidateAntiForgeryToken]
        [ValidateInput(false)]
        public ActionResult SendMail(string mailName,string account, string title, string content)
        {
            MailHelper mail = new MailHelper();
            mail.MailServer = Configs.GetValue("MailHost");
            mail.MailUserName = Configs.GetValue("MailUserName");
            mail.MailPassword = Configs.GetValue("MailPassword");
            mail.MailName = mailName;
            mail.Send(account, title, content,"UTF-8",true,true);
            return Success("发送成功。");
        }

        [HttpGet]
        [HandlerAuthorize]
        public ActionResult Default()
        {
            return View();
        }
    }
}
